﻿/// <reference path="_namespace.js" />
/// <reference path="../../windows/WinFormDisplayFlags.js"/>
/// <reference path="../../windows/WinForm.js" />

/*****************************************************************************
Ajaxna library class definition. Inheriting from ajax.BaseObject.
Author: krobinson 10/16/2008 1:11:39 PM.
Class:  ajax.xna.framework.GameWindow
*****************************************************************************/

$addNamespace("ajax.xna.framework");
$imports("ajax.windows.WinFormDisplayFlags");
//-----------------------------------------------------------------------------

ajax.xna.framework.GameWindow = function(doc, sLayerName, w, h, displayFlags, sText, parentNode, bModal, taskBar)
{///<param name="doc" type="domDocument"/>
 ///<param name="sLayerName" type="String">Optional. Pass a blank string fo no custom id.</param>
 ///<param name="w" type="number">Optional. The outer width.</param>
 ///<param name="h" type="number">Optional. The outer height.</param>
 ///<param name="displayFlags" type="ajax.windows.WinFormDisplayFlags"/>Optional. Can be OR'ed. </param>
 ///<param name="sText" type="String">Optional. The window caption.</param>
 ///<param name="parentNode" type="domElement">Optional. The Dom element to append the window to.</param>
 ///<param name="bModal" type="boolean">Optional. Pass true for modal, false otherwise.</param>
 ///<param name="taskBar" type="domElement">Optional. Pass a dom element that acts as a taskbar.</param>
    ajax.xna.framework.GameWindow.superConstructor.call(this, doc, sLayerName, w, h, displayFlags, sText);
}
$extend("ajax.xna.framework.GameWindow", "ajax.windows.WinForm");
if ($getDesignMode())
    ajax.xna.framework.GameWindow.prototype = ajax.windows.WinForm.prototype;
//-----------------------------------------------------------------------------

// Private members
ajax.xna.framework.GameWindow.prototype._allowUserResizing = false;

// Public members
//-----------------------------------------------------------------------------
ajax.xna.framework.GameWindow.prototype.get_allowUserResizing = function()
{///<value type="boolean"/>
    return this._allowUserResizing;
}
ajax.xna.framework.GameWindow.prototype.set_allowUserResizing = function(value) 
{
    this._allowUserResizing = value;
    this.processDisplayFlags(this.displayFlags);
}

// Overrides
//-----------------------------------------------------------------------------
ajax.xna.framework.GameWindow.prototype.processDisplayFlags = function(newFlags)
{///<param name="newFlags" type="ajax.windows.WinFormDisplayFlags"/>
    newFlags = ajax.isDefined(newFlags) ? newFlags : this.displayFlags;
    
    // By default - OR in the no resize rule.
    newFlags |= ajax.windows.WinFormDisplayFlags.NoResize | ajax.windows.WinFormDisplayFlags.NoMaximise;
    if (this._allowUserResizing) // Allow resize please.
        newFlags -= ajax.windows.WinFormDisplayFlags.NoResize | ajax.windows.WinFormDisplayFlags.NoMaximise;
        
    ajax.xna.framework.GameWindow.superClass.processDisplayFlags.call(this, newFlags);
}

// Public Methods
//-----------------------------------------------------------------------------


// Statics
//-----------------------------------------------------------------------------
ajax.xna.framework.GameWindow.cast = function(obj)
{///<returns type="ajax.xna.framework.GameWindow"/>
    return obj;
}